import java.util.Random;
import java.util.Scanner;

public class 口算答题卡 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Random random = new Random();
        int tiliang;        //题量
        int szfwzdz;        //数字范围最大值
        int ddtm = 0,dote =0;           //答对题目//答错题数

        System.out.println("请输入题目数量");
        tiliang = input.nextInt();

        System.out.println("请输入数字范围最大值");
        szfwzdz = input.nextInt();

        for (int i = 1; i <= tiliang; i++) {

            int num1 = random.nextInt(szfwzdz);
            int num2 = random.nextInt(szfwzdz);
            int operator = random.nextInt(4);

            String op_string = "";

            switch (operator) {
                case 0:
                    op_string = "+";
                    break;
                case 1:
                    op_string = "-";
                    break;
                case 2:
                    op_string = "*";
                    break;
                case 3:
                    op_string = "/";
                    break;
            }
            System.out.println(i + "." + num1 + " " + op_string + "  " + num2 + " = ");
            int user_answer = input.nextInt();
            int correct_acswer = 0;

            switch (operator) {
                case 0:
                    correct_acswer = num1 + num2;
                    break;
                case 1:
                    correct_acswer = num1 - num2;
                    break;
                case 2:
                    correct_acswer = num1 * num2;
                    break;
                case 3:
                    correct_acswer = num1 / num2;
                    break;
            }

            if (user_answer == correct_acswer) {
                System.out.println("回答正确");
                ddtm++;
            } else {
                System.out.println("回答错误！正确答案为：" + correct_acswer);
            }
            System.out.println("答题完成！ 共答对 " + ddtm + "答错：" + (tiliang - ddtm) + "答对");
            System.out.println("继续作答请敲1---退出程序请输2");



        }



    }

}

